#!/usr/bin/perl
use strict;
use vars qw { $idx };
$idx = 0; mkdir("./unbinhex-output", 0755); while(<STDIN>) {
chomp; unbinhex($idx, $_); $idx++;
} exit(0);
sub unbinhex {
my($idx, $data) = @_;
my $j = 0;
my $filename = "./unbinhex-output/$idx.png"; next if int(length($data))<128;
open(OUT, ">$filename") || die "$filename: $!"; while($j < length($data)) {
my $hex = "0x" . substr($data, $j, 2); print OUT chr(hex($hex));
$j += 2;
}
close(OUT); }